﻿
/// <summary>
/// Summary description for Category
/// </summary>
public class Category
{
	public long CategoryID { get; private set; }
	public string Title { get; private set; }

	public Category(long id, string title)
	{
		CategoryID = id;
		Title = title;
	}

    public void GetArticleStatus(long articleCategoryID, out bool featured,
        out bool published)
    {
        featured = published = false;

        if(articleCategoryID == CategoryID + (int)ArticleCategoryStatus.NotPublishedFeatured)
            featured = true;
        else if(articleCategoryID == CategoryID + (int)ArticleCategoryStatus.PublishedFeatured)
            published = featured = true;
        else if(articleCategoryID == CategoryID + (int)ArticleCategoryStatus.PublishedNotFeatured)
            published = true;
    }

    public bool IsCategory(long articleCategoryID)
    {
        return CategoryID == articleCategoryID 
            || CategoryID + (int)ArticleCategoryStatus.NotPublishedFeatured == articleCategoryID
            || CategoryID + (int)ArticleCategoryStatus.NotPublishedNotFeatured == articleCategoryID
            || CategoryID + (int)ArticleCategoryStatus.PublishedFeatured == articleCategoryID
            || CategoryID + (int)ArticleCategoryStatus.PublishedNotFeatured == articleCategoryID;
    }

    public bool Published(long articleCategoryID)
    {
        return (articleCategoryID == CategoryID + (int)ArticleCategoryStatus.PublishedFeatured
            || articleCategoryID == CategoryID + (int)ArticleCategoryStatus.PublishedNotFeatured);
    }

    public bool Featured(long articleCategoryID)
    {
        return (articleCategoryID == CategoryID + (int)ArticleCategoryStatus.PublishedFeatured
            || articleCategoryID == CategoryID + (int)ArticleCategoryStatus.NotPublishedFeatured);
    }

    public long GetArticleCategoryID(bool featured, bool published)
    {
        if(featured)
        {
            if(published)
                return CategoryID + (int)ArticleCategoryStatus.PublishedFeatured;
            else
                return CategoryID + (int)ArticleCategoryStatus.NotPublishedFeatured;
        }
        else
        {
            if(published)
                return CategoryID + (int)ArticleCategoryStatus.PublishedNotFeatured;
            else
                return CategoryID + (int)ArticleCategoryStatus.NotPublishedNotFeatured;
        }
    }
}

